<template>
    <div>
        <span @click="removeCount">-</span>
        <span>{{num}}</span>
        <span @click="addCount">+</span>
    </div>
</template>

<script>
import {mapActions} from 'vuex';
export default {
    props:{
        num:{
            type:Number,
            default:1
        },
        shopid:{
            type:Number,
            default:-1
        }
    },
    methods:{
        ...mapActions('car',['addCarAction','removeCarAction','delCarAction']),
        addCount(){
            this.addCarAction(this.shopid);
        },
        removeCount(){
            if(this.num > 1){
                this.removeCarAction(this.shopid);
            }else{
                this.delCarAction(this.shopid);
            }
        }
    }
}
</script>